<?php
class WorkDayControl extends CI_Controller{
	public function __construct()
	{
		parent::__construct();
		$this->load->helper('url');
		$this->load->model('work_day_model');
		$this->load->model('employe_info_model');
		//		$this->load->library('calendar');
		$this->load->library('pagination');
		$this->load->database();
		$this->load->library('session');
	}

	function index(){
		$this->load->library('pagination');
		$config['base_url'] = base_url().'/employeInfoControl/index/';
		$config['total_rows'] = $this->db->count_all('employe_info');
		$config['per_page'] = '7';
		$config['full_tag_open'] = '<p>';
		$config['full_tag_close'] = '</p>';

		$this->pagination->initialize($config);
		$this->load->model('employe_info_model');
		$data['query'] = $this->employe_info_model->getEmployeInfo($config['per_page'],$this->uri->segment(3));
		$this->load->view('admin/workDay/workDay_index', $data);
		//		$config['base_url'] = base_url().'/workDayControl/index/';
		//		$config['total_rows'] = $this->db->count_all('emp_workday');
		//		$config['per_page'] = '7';
		//		$config['full_tag_open'] = '<p>';
		//		$config['full_tag_close'] = '</p>';
		//
		//		$this->pagination->initialize($config);
		//		$this->load->model('work_day_model');
		//		$data['query'] = $this->work_day_model->getWorkDay($config['per_page'],$this->uri->segment(3));
		//		$this->load->view('admin/workDay/workDay_index', $data);
	}

	function add(){
		$prefs = array (
			'show_next_prev'  => TRUE,
	        'next_prev_url'   => 'http://127.0.0.1/salon/workDayControl/add/'
	        );
	        $this->load->library('calendar', $prefs);
	        $data['query'] = $this->employe_info_model->getAllEmployeInfo();
	        $this->load->view('admin/workDay/workDay_add',$data);
	}

	function doAdd(){
		$id = $this->work_day_model->addWorkDay();
		//		$sess_data = array(
		//			'login_s' => True
		//		);
		//		$this->session->set_userdata($sess_data);
		redirect('workDayControl/update/'.$_POST['employeid'],'refresh');
	}

	function update(){
		$id = $this->uri->segment(3);
		$data['query']=$this->work_day_model->getWorkDayByEmployeId($id);
		$this->load->view('admin/workDay/workDay_edit',$data,$id);
	}

	function doUpdate(){
		$msg="";
		$data=array(
				'id'=>$_POST['id'],
				'employeid'=>$_POST['employeid'], 
				'workday'=>$_POST['workday'],
				'shour'=>$_POST['shour'],
				'sminute'=>$_POST['sminute'],
				'ehour'=>$_POST['ehour'],
				'eminute'=>$_POST['eminute']
		);
		$employeid = $this->work_day_model->updateWorkDay($_POST['id'],$data);
		//		redirect('workDayControl/index/'.$_POST['id'],'refresh');
	}

	function delete(){
		$id = $this->uri->segment(3);
		$employeid = $this->work_day_model->delWorkDayById($id);
		redirect('workDayControl/update/'.$employeid,'refresh');
			
	}
}

?>